package com.niuwa.p2p.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.stereotype.Controller;

import com.niuwa.p2p.core.mvc.entity.JsonResult;
import com.niuwa.p2p.core.utils.DictUtil;

@Namespace("/dict")
@Controller
public class DictAction extends JsonAction {

    private static final long serialVersionUID = 1L;

    private String dictType;
    private String parentDictId;

    @Action("index")
    public String index() {
        setResult(new JsonResult(DictUtil.getDictionaryByDictType(dictType)));
        return NONE;
    }

    @Action("parent")
    public String parent() {
        setResult(new JsonResult(DictUtil.getDictListByParentDictId(parentDictId, dictType)));
        return NONE;
    }

    @Action("test")
    public String test() {

        return "test";
    }

    public String getDictType() {
        return dictType;
    }

    public void setDictType(String dictType) {
        this.dictType = dictType;
    }

    public String getParentDictId() {
        return parentDictId;
    }

    public void setParentDictId(String parentDictId) {
        this.parentDictId = parentDictId;
    }

}
